﻿@model ContactManagement.Models.DynamicData.EditModelList
@{
    ViewBag.Title = GlobalResources.PageTitles.EditDynamicDataTypeRESX + ": " + Model.CurrentDynamicDataType.Name;
}

<div class="span12">
    <h2>@GlobalResources.PageTitles.EditDynamicDataTypeRESX: @Model.CurrentDynamicDataType.Name
        (@Model.CurrentDynamicDataType.GetDynamicDataTypeName())</h2>
    <hr />
    <div class="well">@string.Format(GlobalResources.AdminViews.CreateNewListEntryHelpRESX, GlobalResources.AdminViews.NewListEntryRESX)
    </div>
</div>

<div class="span12">
    @using (Html.BeginForm(EActionDynamicData.List.ToString(), EControllers.DynamicData.ToString(), FormMethod.Post, new { @class = "form-horizontal" }))
    {
        <fieldset>
            @Html.MyValidationSummary()
            @Html.ShowCustomMessage()

            <div class="control-group">
                @Html.LabelFor(model => model.Name, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.DynamicDataTypeCategories, new { @class = "control-label" })
                <div class="controls">
                    @Html.DropDownListFor(model => model.DynamicDataTypeCategoryId, Model.DynamicDataTypeCategories, GlobalResources.GlobalStrings.PleaseSelectItemsRESX)
                    @Html.ValidationMessageFor(model => model.DynamicDataTypeCategoryId)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.IsRequired, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.IsRequired)
                    @Html.ValidationMessageFor(model => model.IsRequired)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.FormatString, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.FormatString)
                    @Html.ValidationMessageFor(model => model.FormatString)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.IsVisible, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.IsVisible)
                    @Html.ValidationMessageFor(model => model.IsVisible)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.SortId, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.SortId)
                    @Html.ValidationMessageFor(model => model.SortId)
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(model => model.CustomCssClass, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.CustomCssClass)
                    @Html.ValidationMessageFor(model => model.CustomCssClass)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.IsFilterable, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.IsFilterable)
                    @Html.ValidationMessageFor(model => model.IsFilterable)
                </div>
            </div>

            <div class="control-group">
                @Html.LabelFor(model => model.Description, new { @class = "control-label" })
                <div class="controls">
                    @Html.EditorFor(model => model.Description)
                    @Html.ValidationMessageFor(model => model.Description)
                </div>
            </div>


            <div class="control-group">
                @Html.LabelFor(model => model.ListEntries)
                <div class="controls">
                    <table class="table table-striped table-condensed">
                        <tr>
                            <th>
                                @GlobalResources.AccountViews.OptionsRESX
                            </th>
                            <th>
                                @GlobalResources.AdminViews.ListEntryNameRESX
                            </th>
                            <th>
                                @GlobalResources.AdminViews.SortIDRESX
                            </th>
                        </tr>
                        @foreach (var eListEnty in Model.ListEntries)
                        {
                            <tr>
                                <td>
                                    @if (eListEnty.ID > 0)
                                    {
                                        // Einen Link zum Löschen des aktuellen Listeneintrages, dieser kann letztendlich aber nur gelöscht werden wenn der Eintrag noch nicht verwendet wird, bzw. die Id > 0 ist.
                                        @Html.ActionLink(GlobalResources.Navigation.DeleteRESX, EActionDynamicData.DeleteListEntry.ToString(), new { id = Model.CurrentDynamicDataType.ID, listEntryId = eListEnty.ID }, new { @class = "btn btn-small", data_icon = "icon-minus" })
                                    }
                                    else
                                    {
                                        @GlobalResources.AdminViews.NewListEntryRESX
                                    }
                                </td>
                                <td>
                                    <input id="@String.Format("{0}_{1}", WebConstants.ListEntryName, eListEnty.ID)" type="text" value="@eListEnty.Name" placeholder="@GlobalResources.AdminViews.ListEntryNameRESX" name="@String.Format("{0}_{1}", WebConstants.ListEntryName, eListEnty.ID)" class="span2" />
                                </td>
                                <td>
                                    <input id="@String.Format("{0}_{1}", WebConstants.ListEntrySortId, eListEnty.ID)" type="text" value="@eListEnty.SortId" placeholder="@GlobalResources.AdminViews.SortIDRESX" name="@String.Format("{0}_{1}", WebConstants.ListEntrySortId, eListEnty.ID)" class="span2" />
                                </td>
                            </tr>
                        }
                    </table>
                </div>
            </div>

            <div class="form-actions">
                <input class="btn btn-primary" type="submit" value="@GlobalResources.Navigation.SaveChangesRESX" />
            </div>
        </fieldset>
    }
</div>

<div class="span12">
    <div class="well">
        @Html.ActionLink(@GlobalResources.Navigation.BackToListRESX, EActionDynamicData.DynamicDataTypesList.ToString(), null, new { @class = "btn btn-small", data_icon = "icon-arrow-left" })
        @Html.ActionLink(@GlobalResources.Navigation.DynamicDataEditGroupRightsRESX, EActionDynamicData.EditGroupRights.ToString(), new { id = Model.CurrentDynamicDataType.ID }, new { @class = "btn btn-small" })
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
